home *** CD-ROM | disk | FTP | other *** search
/ Quick PC 61 / Quick PC 61.iso / I386 / SASETUP.MSI / F77648_groups.asp < prev    next >
Encoding:
Text File  |  2003-02-21  |  15.5 KB  |  502 lines

  1. <%@ Language=VBScript       %>
  2. <%    Option Explicit            %>
  3. <%
  4.     '-------------------------------------------------------------------------
  5.     ' groups.asp: Group area page - lists all the Groups,and provides
  6.     '                links for creating new groups,editing and deleting groups
  7.     '
  8.     ' Copyright (c) Microsoft Corporation.  All rights reserved. 
  9.     '
  10.     ' Date            Description
  11.     ' 15-Jan-2001    Creation date
  12.     '-------------------------------------------------------------------------
  13. %>
  14.     <!-- #include virtual="/admin/inc_framework.asp" -->
  15.     <!-- #include virtual="/admin/ots_main.asp" -->
  16. <%
  17.     '-------------------------------------------------------------------------
  18.     ' Global Constants
  19.     '-------------------------------------------------------------------------
  20.     Const NAME_COLUMN = 0
  21.     Const DESCRIPTION_COLUMN = 1
  22.     Const GROUPS_PER_PAGE = 100
  23.  
  24.     '
  25.     ' Name of this source file
  26.     Const SOURCE_FILE = "Groups.asp"
  27.     '
  28.     ' Flag to toggle optional tracing output
  29.     Const ENABLE_TRACING = TRUE
  30.     
  31.     '-------------------------------------------------------------------------
  32.     ' Global Variables
  33.     '-------------------------------------------------------------------------
  34.     Dim g_bSearchChanged
  35.     Dim g_iSearchCol
  36.     Dim g_sSearchColValue
  37.  
  38.     Dim g_bPagingInitialized
  39.     Dim g_bPageChangeRequested
  40.     Dim g_sPageAction
  41.     Dim g_iPageMin
  42.     Dim g_iPageMax
  43.     Dim g_iPageCurrent
  44.  
  45.     Dim g_bSortRequested
  46.     Dim g_iSortCol
  47.     Dim g_sSortSequence
  48.     
  49.     '-------------------------------------------------------------------------
  50.     ' Local Variables
  51.     '-------------------------------------------------------------------------
  52.     
  53.     Dim page
  54.     DIM L_APPLIANCE_GROUPS
  55.     DIM L_DESCRIPTION_HEADING
  56.     DIM L_COLUMN_NAME
  57.     DIM L_COLUMN_FULLNAME
  58.     DIM L_TASKS_TEXT
  59.     DIM L_NEW_TEXT
  60.     DIM L_DELETE_TEXT
  61.     DIM L_PROPERTIES_TEXT
  62.     DIM L_NEW_ROLLOVERTEXT
  63.     DIM L_DELETE_ROLLOVERTEXT
  64.     DIM L_PROPERTIES_ROLLOVERTEXT
  65.     'error messages
  66.     Dim L_FAILEDTOGETGROUPS_ERRORMESSAGE
  67.     
  68.     
  69.     L_APPLIANCE_GROUPS = GetLocString("usermsg.dll", "&H4031001C", "")
  70.     L_DESCRIPTION_HEADING = GetLocString("usermsg.dll", "&H4031001D", "")
  71.     L_COLUMN_NAME = GetLocString("usermsg.dll", "&H4031001E", "")
  72.     L_COLUMN_FULLNAME = GetLocString("usermsg.dll", "&H4031001F", "")
  73.     L_TASKS_TEXT = GetLocString("usermsg.dll", "&H40310020", "")
  74.     L_NEW_TEXT = GetLocString("usermsg.dll", "&H40310021", "")
  75.     L_DELETE_TEXT = GetLocString("usermsg.dll", "&H40310022", "")
  76.     L_PROPERTIES_TEXT = GetLocString("usermsg.dll", "&H40310023", "")
  77.     L_NEW_ROLLOVERTEXT = GetLocString("usermsg.dll", "&H40310024", "")
  78.     L_DELETE_ROLLOVERTEXT = GetLocString("usermsg.dll", "&H40310025", "")
  79.     L_PROPERTIES_ROLLOVERTEXT = GetLocString("usermsg.dll", "&H40310026", "")
  80.     
  81.     'error messages
  82.     L_FAILEDTOGETGROUPS_ERRORMESSAGE = GetLocString("usermsg.dll", "&HC031002E", "")
  83.     
  84.     '
  85.     ' Create Page
  86.     Call SA_CreatePage( L_APPLIANCE_GROUPS, "", PT_AREA, page )
  87.  
  88.     '
  89.     ' Show page
  90.     Call SA_ShowPage( page )
  91.     '---------------------------------------------------------------------
  92.     ' Function name:    OnInitPage
  93.     ' Description:        Called to signal first time processing for this page. 
  94.     ' Input Variables:    PageIn and EventArg
  95.     ' Output Variables:    None
  96.     ' Return Values:    TRUE to indicate initialization was successful. FALSE to indicate
  97.     '                    errors. Returning FALSE will cause the page to be abandoned.
  98.     ' Global Variables: None
  99.     ' Called to signal first time processing for this page. Use this method
  100.     ' to do first time initialization tasks. 
  101.     '---------------------------------------------------------------------
  102.     Public Function OnInitPage(ByRef PageIn, ByRef EventArg)
  103.         OnInitPage = TRUE
  104.         
  105.         If ( ENABLE_TRACING ) Then 
  106.             Call SA_TraceOut(SOURCE_FILE, "OnInitPage")
  107.         End If
  108.             
  109.         g_bPagingInitialized = FALSE
  110.         g_iPageCurrent = 1
  111.         
  112.         g_iSortCol = 0
  113.         g_sSortSequence = "A"
  114.     End Function
  115.  
  116.     '---------------------------------------------------------------------
  117.     ' Function name:    OnServeAreaPage
  118.     ' Description:        Called when the page needs to be served. 
  119.     ' Input Variables:    PageIn, EventArg
  120.     ' Output Variables:    None
  121.     ' Return Values:    TRUE to indicate no problems occured. FALSE to indicate errors.
  122.     '                    Returning FALSE will cause the page to be abandoned.
  123.     ' Global Variables: In:g_bPageChangeRequested,g_sPageAction,
  124.     '                    g_bSearchRequested,g_iSearchCol,g_sSearchColValue
  125.     '                    In:L_(*)-Localization Strings
  126.     ' Called when the page needs to be served. Use this method to serve content.
  127.     '---------------------------------------------------------------------
  128.     Public Function OnServeAreaPage(ByRef PageIn, ByRef EventArg)
  129.         If ( ENABLE_TRACING ) Then 
  130.             Call SA_TraceOut(SOURCE_FILE, "OnServeAreaPage")
  131.         End If
  132.         
  133.         Dim tableGroup
  134.         Dim colFlags
  135.         Dim iGroupCount
  136.         Dim nReturnValue
  137.         Dim strFlag
  138.         Dim strUrlBase
  139.         
  140.         strFlag="noval"
  141.         
  142.         ' Create the table
  143.         '
  144.         tableGroup = OTS_CreateTable("", L_DESCRIPTION_HEADING)
  145.  
  146.  
  147.         '
  148.         ' If the search criteria changed then we need to recompute the paging range
  149.         If ( TRUE = g_bSearchChanged ) Then
  150.             '
  151.             ' Need to recalculate the paging range
  152.             g_bPagingInitialized = FALSE
  153.             '
  154.             ' Restarting on page #1
  155.             g_iPageCurrent = 1
  156.         End If
  157.  
  158.  
  159.         '
  160.         ' Name column is searchable and is contains key to row
  161.         colFlags = (OTS_COL_SORT OR OTS_COL_SEARCH OR OTS_COL_KEY)
  162.         '
  163.         ' Create the column and add it to the table
  164.         nReturnValue= OTS_AddTableColumn(tableGroup, OTS_CreateColumnEx( L_COLUMN_NAME, "left", colFlags, 25 ))
  165.         If nReturnValue <> gc_ERR_SUCCESS Then
  166.             SA_ServeFailurePage L_OTS_ADDCOLOUMNFAIL_ERRORMESSAGE
  167.             OnServeAreaPage = false
  168.             Exit Function
  169.         End IF
  170.  
  171.         '
  172.         ' Description is searchable
  173.         colFlags = OTS_COL_SORT OR OTS_COL_SEARCH
  174.         '
  175.         ' Create the column and add it to the table
  176.         nReturnValue=OTS_AddTableColumn(tableGroup, OTS_CreateColumnEx( L_COLUMN_FULLNAME, "left", colFlags, 50))
  177.         If nReturnValue <> gc_ERR_SUCCESS Then
  178.             SA_ServeFailurePage L_OTS_ADDCOLOUMNFAIL_ERRORMESSAGE
  179.             OnServeAreaPage = false
  180.             Exit Function
  181.         End IF
  182.         
  183.  
  184.         '
  185.         ' Fetch the list of groups and add them to the table
  186.         '
  187.         Dim objContainer
  188.         Dim objGroup
  189.  
  190.         '
  191.         ' ADSI call to get the local computer object
  192.         Set objContainer = GetObject("WinNT://" + GetComputerName() )
  193.         '
  194.         ' ADSI call to get the collection of local groups
  195.         objContainer.Filter = Array("Group")
  196.  
  197.         iGroupCount = 0
  198.         For Each objGroup in objContainer
  199.             If ( Len( g_sSearchColValue ) <= 0 ) Then
  200.                 '
  201.                 ' Search criteria blank, select all rows
  202.                 '
  203.                 iGroupCount = iGroupCount + 1
  204.  
  205.                 '
  206.                 ' Verify that the current group is part of the current page
  207.                 If ( IsItemOnPage( iGroupCount, g_iPageCurrent, GROUPS_PER_PAGE) ) Then
  208.                     Call OTS_AddTableRow( tableGroup, Array(objGroup.Name, objGroup.Description))
  209.                     strFlag="yesval"
  210.                 End If
  211.                 
  212.             Else
  213.                 '
  214.                 ' Check the Search criteria
  215.                 '
  216.                 Select Case (g_iSearchCol)
  217.                     
  218.                     Case NAME_COLUMN
  219.                         If ( InStr(1, objGroup.Name, g_sSearchColValue, 1) ) Then
  220.                             iGroupCount = iGroupCount + 1
  221.                             '
  222.                             ' Verify that the current group part of the current page
  223.                             If ( IsItemOnPage( iGroupCount, g_iPageCurrent, GROUPS_PER_PAGE) ) Then
  224.                                 Call OTS_AddTableRow( tableGroup, Array(objGroup.Name, objGroup.Description))
  225.                                 strFlag="yesval"
  226.                             End If
  227.                         End If
  228.                             
  229.                     Case DESCRIPTION_COLUMN
  230.                         If ( InStr(1, objGroup.Description, g_sSearchColValue, 1) ) Then
  231.                             iGroupCount = iGroupCount + 1
  232.                             '
  233.                             ' Verify that the current group part of the current page
  234.                             If ( IsItemOnPage( iGroupCount, g_iPageCurrent, GROUPS_PER_PAGE) ) Then
  235.                                 Call OTS_AddTableRow( tableGroup, Array(objGroup.Name, objGroup.Description))
  236.                                 strFlag="yesval"
  237.                             End If
  238.                         End If
  239.                             
  240.                     Case Else
  241.                         Call SA_TraceOut(SOURCE_FILE, "Unrecognized search column: " + CStr(g_iSearchCol))
  242.                         iGroupCount = iGroupCount + 1
  243.                         '
  244.                         ' Verify that the current group part of the current page
  245.                         If ( IsItemOnPage( iGroupCount, g_iPageCurrent, GROUPS_PER_PAGE) ) Then
  246.                             Call OTS_AddTableRow( tableGroup, Array(objGroup.Name, objGroup.Description))
  247.                             strFlag="yesval"
  248.                         End If
  249.                 End Select
  250.             End If
  251.             
  252.         Next
  253.         
  254.         '
  255.         ' Set Tasks section title
  256.         Call OTS_SetTableTasksTitle(tableGroup, L_TASKS_TEXT)
  257.  
  258.         '
  259.         ' Add the tasks associated with Group objects
  260.         strUrlBase = "users/group_new.asp"
  261.         call SA_MungeURL(strUrlBase,"Tab1",GetTab1())
  262.         call SA_MungeURL(strUrlBase,"Tab2",GetTab2())    
  263.         Call OTS_AddTableTask( tableGroup, OTS_CreateTaskEx(L_NEW_TEXT, _
  264.                                         L_NEW_ROLLOVERTEXT, _
  265.                                         strUrlBase,_
  266.                                         OTS_PT_TABBED_PROPERTY, "OTS_TaskAlways") )
  267.                                         
  268.         strUrlBase = "users/group_delete.asp"
  269.         call SA_MungeURL(strUrlBase,"Tab1",GetTab1())
  270.         call SA_MungeURL(strUrlBase,"Tab2",GetTab2())    
  271.         Call OTS_AddTableTask( tableGroup, OTS_CreateTaskEx(L_DELETE_TEXT, _
  272.                                             L_DELETE_ROLLOVERTEXT, _
  273.                                             strUrlBase,_
  274.                                             OTS_PT_PROPERTY, "OTS_TaskAny") )
  275.                                             
  276.         strUrlBase = "users/group_prop.asp"
  277.         call SA_MungeURL(strUrlBase,"Tab1",GetTab1())
  278.         call SA_MungeURL(strUrlBase,"Tab2",GetTab2())    
  279.         Call OTS_AddTableTask( tableGroup, OTS_CreateTaskEx(L_PROPERTIES_TEXT, _
  280.                                             L_PROPERTIES_ROLLOVERTEXT, _
  281.                                             strUrlBase,_
  282.                                             OTS_PT_TABBED_PROPERTY, "OTS_TaskOne") )
  283.         
  284.         Set objContainer = Nothing
  285.  
  286.         
  287.         '
  288.         ' Enable paging feature
  289.         '
  290.         Call OTS_EnablePaging(tableGroup, TRUE)
  291.         
  292.         '
  293.         ' If paging range needs to be initialised then
  294.         ' we need to figure out how many pages we are going to display
  295.         If ( FALSE = g_bPagingInitialized ) Then
  296.             g_iPageMin = 1
  297.             
  298.             g_iPageMax = Int(iGroupCount / GROUPS_PER_PAGE )
  299.             If ( (iGroupCount MOD GROUPS_PER_PAGE) > 0 ) Then
  300.                 g_iPageMax = g_iPageMax + 1
  301.             End If
  302.             
  303.             g_iPageCurrent = 1
  304.             Call OTS_SetPagingRange(tableGroup, g_iPageMin, g_iPageMax, g_iPageCurrent)
  305.         End If
  306.  
  307.                                 
  308.         '
  309.         ' Sort the table
  310.         '
  311.         Call OTS_SortTable(tableGroup, g_iSortCol, g_sSortSequence, SA_RESERVED)
  312.         
  313.         '
  314.         ' Set MultiSelection enabled
  315.         '
  316.         Call OTS_SetTableMultiSelection(tableGroup,TRUE)        
  317.         
  318.         '
  319.         ' Send table to the response stream
  320.         '
  321.         Call OTS_ServeTable(tableGroup)
  322.  
  323.         '
  324.         ' All done...
  325.         OnServeAreaPage = TRUE
  326.     End Function
  327.  
  328.  
  329.  
  330.     '---------------------------------------------------------------------
  331.     ' Function name:    OnSearchNotify()
  332.     ' Description:        Search notification event handler. When one or more columns are
  333.     '                    marked with the OTS_COL_SEARCH flag, the Web Framework fires
  334.     '                    this event
  335.     ' Input Variables:    PageIn,EventArg,sItem,sValue
  336.     ' Output Variables:    PageIn,EventArg,sItem,sValue
  337.     ' Returns:    Always returns TRUE
  338.     '---------------------------------------------------------------------
  339.     Public Function OnSearchNotify(ByRef PageIn, _
  340.                                         ByRef EventArg, _
  341.                                         ByRef sItem, _
  342.                                         ByRef sValue )
  343.             OnSearchNotify = TRUE
  344.  
  345.             '
  346.             ' User pressed the search GO button
  347.             '
  348.             If SA_IsChangeEvent(EventArg) Then
  349.                 If ( ENABLE_TRACING ) Then 
  350.                     Call SA_TraceOut(SOURCE_FILE, "OnSearchNotify() Change Event Fired")
  351.                 End If
  352.                 g_bSearchChanged = TRUE
  353.                 g_iSearchCol = Int(sItem)
  354.                 g_sSearchColValue = CStr(sValue)
  355.             '
  356.             ' User clicked a column sort, OR clicked either the page next or page prev button
  357.             ElseIf SA_IsPostBackEvent(EventArg) Then
  358.                 If ( ENABLE_TRACING ) Then 
  359.                     Call SA_TraceOut(SOURCE_FILE, "OnSearchNotify() Postback Event Fired")
  360.                 End If
  361.                 g_bSearchChanged = FALSE
  362.                 g_iSearchCol = Int(sItem)
  363.                 g_sSearchColValue = CStr(sValue)
  364.             '
  365.             ' Unknown event source
  366.             Else
  367.                 If ( ENABLE_TRACING ) Then 
  368.                     Call SA_TraceOut(SOURCE_FILE, "Unrecognized Event in OnSearchNotify()")
  369.                 End If
  370.             End IF
  371.             
  372.             
  373.     End Function
  374.  
  375.     '---------------------------------------------------------------------
  376.     ' Function:            OnPagingNotify()
  377.     ' Function name:    OnPagingNotify()
  378.     ' Description:        Paging notification event handler.                
  379.     ' Input Variables:    PageIn,EventArg,sPageAction,iPageMin,iPageMax,iPageCurrent
  380.     ' Output Variables:    PageIn,EventArg
  381.     ' Return Values:    Always returns TRUE
  382.     ' Global Variables: G_*
  383.     '---------------------------------------------------------------------
  384.     Public Function OnPagingNotify(ByRef PageIn, _
  385.                                         ByRef EventArg, _
  386.                                         ByVal sPageAction, _
  387.                                         ByVal iPageMin, _
  388.                                         ByVal iPageMax, _
  389.                                         ByVal iPageCurrent )
  390.             OnPagingNotify = TRUE
  391.             
  392.             g_bPagingInitialized = TRUE
  393.             
  394.             '
  395.             ' User pressed either page next or page previous
  396.             '
  397.             If SA_IsChangeEvent(EventArg) Then
  398.                 If ( ENABLE_TRACING ) Then 
  399.                     Call SA_TraceOut(SOURCE_FILE, "OnPagingNotify() Change Event Fired")
  400.                 End If
  401.                 g_bPageChangeRequested = TRUE
  402.                 g_sPageAction = CStr(sPageAction)
  403.                 g_iPageMin = iPageMin
  404.                 g_iPageMax = iPageMax
  405.                 g_iPageCurrent = iPageCurrent
  406.             '
  407.             ' User clicked a column sort OR the search GO button
  408.             ElseIf SA_IsPostBackEvent(EventArg) Then
  409.                 If ( ENABLE_TRACING ) Then 
  410.                     Call SA_TraceOut(SOURCE_FILE, "OnPagingNotify() Postback Event Fired")
  411.                 End If
  412.                 g_bPageChangeRequested = FALSE
  413.                 g_sPageAction = CStr(sPageAction)
  414.                 g_iPageMin = iPageMin
  415.                 g_iPageMax = iPageMax
  416.                 g_iPageCurrent = iPageCurrent
  417.             '
  418.             ' Unknown event source
  419.             Else
  420.                 If ( ENABLE_TRACING ) Then 
  421.                     Call SA_TraceOut(SOURCE_FILE, "Unrecognized Event in OnPagingNotify()")
  422.                 End If
  423.             End IF
  424.             
  425.     End Function
  426.  
  427.  
  428.     '---------------------------------------------------------------------
  429.     ' Function:            OnSortNotify()
  430.     ' Function name:    GetServices
  431.     ' Description:        Sorting notification event handler.
  432.     ' Input Variables:    PageIn,EventArg,sortCol,sortSeq
  433.     ' Output Variables:    PageIn,EventArg
  434.     ' Return Values:    Always returns TRUE
  435.     ' Global Variables: G_*
  436.     '---------------------------------------------------------------------
  437.     Public Function OnSortNotify(ByRef PageIn, _
  438.                                         ByRef EventArg, _
  439.                                         ByVal sortCol, _
  440.                                         ByVal sortSeq )
  441.             OnSortNotify = TRUE
  442.             
  443.             '
  444.             ' User pressed column sort
  445.             '
  446.             If SA_IsChangeEvent(EventArg) Then
  447.                 If ( ENABLE_TRACING ) Then 
  448.                     Call SA_TraceOut(SOURCE_FILE, "OnSortNotify() Change Event Fired")
  449.                 End If
  450.                 g_iSortCol = sortCol
  451.                 g_sSortSequence = sortSeq
  452.                 g_bSortRequested = TRUE
  453.             '
  454.             ' User presed the search GO button OR clicked either the page next or page prev button
  455.             ElseIf SA_IsPostBackEvent(EventArg) Then
  456.                 If ( ENABLE_TRACING ) Then 
  457.                     Call SA_TraceOut(SOURCE_FILE, "OnSortNotify() Postback Event Fired")
  458.                 End If
  459.                 g_iSortCol = sortCol
  460.                 g_sSortSequence = sortSeq
  461.                 g_bSortRequested = TRUE
  462.             '
  463.             ' Unknown event source
  464.             Else
  465.                 If ( ENABLE_TRACING ) Then 
  466.                     Call SA_TraceOut(SOURCE_FILE, "Unrecognized Event in OnSearchNotify()")
  467.                 End If
  468.             End IF
  469.             
  470.             If ( ENABLE_TRACING ) Then 
  471.                 Call SA_TraceOut(SOURCE_FILE, "Sort col: " + CStr(sortCol) + "   sequence: " + sortSeq)
  472.             End If
  473.             
  474.     End Function
  475.     '---------------------------------------------------------------------
  476.     ' Function:            IsItemOnPage()
  477.     ' Description:        Verify that the current group part of the current page.
  478.     ' Input Variables:    iCurrentItem
  479.     ' Output Variables:    None
  480.     ' Return Values:    TRUE or FALSE
  481.     ' Global Variables: None
  482.     '---------------------------------------------------------------------
  483.  
  484.     Private Function IsItemOnPage(ByVal iCurrentItem, iCurrentPage, iItemsPerPage)
  485.         Dim iLowerLimit
  486.         Dim iUpperLimit
  487.  
  488.         iLowerLimit = ((iCurrentPage - 1) * iItemsPerPage )
  489.         iUpperLimit = iLowerLimit + iItemsPerPage + 1
  490.         
  491.         If ( iCurrentItem > iLowerLimit AND iCurrentItem < iUpperLimit ) Then
  492.             IsItemOnPage = TRUE
  493.         Else
  494.             IsItemOnPage = FALSE
  495.         End If
  496.         
  497.     End Function
  498.         
  499. %>
  500.  
  501.  
  502.